package net.yebaihe.wc;

import android.content.Context;
import android.content.SharedPreferences;

public class Pref {

	private static final String PREFS_NAME = "WEICAN";
	private static Pref self;
	private Context ctx;

	public static Pref get(Context ctx) {
		if (self==null){
			self=new Pref();
		}
		self.ctx=ctx;
		return self;
	}

	public void save(String key, String value) {
        SharedPreferences settings = ctx.getSharedPreferences(PREFS_NAME, 0);  
		SharedPreferences.Editor editor = settings.edit();  
		editor.putString(key, value);  
		editor.commit();
	}

	public String read(String key, String def){
    	SharedPreferences settings = ctx.getSharedPreferences(PREFS_NAME, 0);  
		return settings.getString(key, def);
	}

}
